#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
  int dfs(int i, int j, vector<vector<int>> &grid, int n, int m)
  {
    if (i >= n || i < 0 || j >= m || j < 0 || grid[i][j] == 0)
      return 0;
    int v = grid[i][j];
    grid[i][j] = 0;
    return v + dfs(i + 1, j, grid, n, m) + dfs(i - 1, j, grid, n, m) + dfs(i, j + 1, grid, n, m) + dfs(i, j - 1, grid, n, m);
  }
  int findMaxFish(vector<vector<int>> &grid)
  {
    int ans = 0;
    int n = grid.size(), m = grid[0].size();
    for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < m; j++)
        ans = max(ans, dfs(i, j, grid, n, m));
    }
    return ans;
  }
};
int main()
{
  Solution s;

  return 0;
}
